package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.StrategyComment;
import cn.wolfcode.trip.base.domain.TravelComment;
import cn.wolfcode.trip.base.mapper.TravelCommentMapper;
import cn.wolfcode.trip.base.query.TravelCommentQueryObject;
import cn.wolfcode.trip.base.service.ITravelCommentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class TravelCommentServiceImpl implements ITravelCommentService {
    @Autowired
    private TravelCommentMapper travelCommentMapper;

    @Override
    public void saveComment(TravelComment travelComment) {
        travelComment.setReleaseTime(new Date());
        travelCommentMapper.saveTravelComment(travelComment);
    }

    @Override
    public PageInfo selectForList(TravelCommentQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<TravelComment> list = travelCommentMapper.selectForList(qo);
        return new PageInfo<>(list);
    }

    @Override
    public Object selectCountById(Long id) {
        return travelCommentMapper.selectCountById(id);
    }
}
